package com.ly.base.chapter02.AAAFuncCitation;
import java.util.stream.Stream;

/**
 * 方法引用: 3、对象:非静态方法引用
 */
public class FuncCitationCObjectNoStatic {
    static class Util{
        public boolean isMale(Student stu){
            return stu.sex().equals("男");
        }

        public String xyz(Student stu){
            return stu.name();
        }
    }
    public static void main(String[] args) {
        Util util = new Util();

        Stream.of(
                        new Student("张无忌", 17, "男"),
                        new Student("周芷若", 20, "女"),
                        new Student("宋青书", 26, "男")
                )
                .filter(util::isMale)
//                .map(stu -> stu.name())
                .map(util::xyz)//过滤，只去姓名
                .forEach(System.out::println);
    }


    record Student(String name,Integer age,String sex){ }

}
